package com.agent.config;

import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AgentConfig {

    // 实现接口，配置会话相关操作：会话记忆、会话隔离、会话存储
    @Bean
    public ChatMemoryProvider chatMemoryProvider() {
        return (memoryId) -> MessageWindowChatMemory.builder()
                .maxMessages(20) // 会话记忆，最大消息数
                .id(memoryId)    // 会话隔离
                .chatMemoryStore(new InMemoryChatMemoryStore()) // 会话存储，基于内存
                .build();
    }

}
